/*******************************************************************************
* Copyright (C) 2019 China Micro Semiconductor Limited Company. All Rights Reserved.
*
* This software is owned and published by:
* CMS LLC, No 2609-10, Taurus Plaza, TaoyuanRoad, NanshanDistrict, Shenzhen, China.
*
* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
*
* This software contains source code for use with CMS
* components. This software is licensed by CMS to be adapted only
* for use in systems utilizing CMS components. CMS shall not be
* responsible for misuse or illegal use of this software for devices not
* supported herein. CMS is providing this software "AS IS" and will
* not be responsible for issues arising from incorrect user implementation
* of the software.
*
* This software may be replicated in part or whole for the licensed use,
* with the restriction that this Disclaimer and Copyright notice must be
* included with each copy of this software, whether used in part or whole,
* at all times.
*/
/*****************************************************************************/
/** \file main.h
**
** 
**
** History:
** 
*****************************************************************************/
#ifndef __USER_FMC_H__
#define __USER_FMC_H__
/*****************************************************************************/
/* Include files */
/*****************************************************************************/



/*****************************************************************************/
/* Global pre-processor symbols/macros ('#define') */
/*****************************************************************************/
#define FMC_BUSY_BIT (1<<5)

#define FMC_UNLOCK()                       do{FMC->LOCK = 0x55AA6699;}while(0)
#define FMC_LOCK()                           do{FMC->LOCK = 0xFFFFFFFF;}while(0)
#define FMC_GET_BUSY_STATE()       (FMC->CON & FMC_BUSY_BIT)
#define FMC_ADDR(addr)                  do{FMC->ADR = (addr);}while(0)
#define FMC_CMD(cmd)		         do{FMC->CMD = cmd;}while(0)
#define FMC_ERROR_ADRESS               1


#define FMC_START_ADRESS               0x1c000000
/*****************************************************************************/
/* Global type definitions ('typedef') */
/*****************************************************************************/
typedef struct
{
	uint32_t data_read[8];
	uint32_t data_write[8];
}USER_FMC_STR;

/*****************************************************************************/
/* Global variable declarations ('extern', definition in C source) */
/*****************************************************************************/

extern USER_FMC_STR strUfmc;
/*****************************************************************************/
/* Global function prototypes ('extern', definition in C source) */
/*****************************************************************************/
void FMC_Init_Variable(void);
void FMC_FMC_Test(void);
void FMC_Write_Data(uint32_t fmc_adress,uint32_t fmc_data);
uint32_t FMC_Read_Data(uint32_t fmc_adress);
void FMC_Write_Array(uint8_t Length);
void FMC_Read_Array(uint8_t Length);


#endif /* __USER_CONTROL_H__ */
